{% extends "static/view/template.html" %}
{% block body %}

<style>
.glyphicon:hover {
    background-color: #ffff00;
    cursor: pointer;
}  

table {
  border: 2px solid #42b983;
  border-radius: 3px;
  background-color: #fff;
}

th {
  background-color: #42b983;
  color:  #fff;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -user-select: none;
}

td {
  background-color: #f9f9f9;
}

th, td {
  min-width: 120px;
  padding: 10px 20px;
}

</style>
<div id="app">
    <div class="container">
        <div class="page-header">
        </div>

        <div class="page-header">
            <h1> <font color= #333333><center>Machine List</center></font>
                <small><center><font color= #778899></font></center></small>
            </h1>
        </div>
    </div>
   
    <div class="row">
        <div class="col-xs-1"></div>
        <div class="col-xs-10">
            <table class="table table-striped" border=0>           
                <tr><th>Machine</th><th>Service</th><th>GPID</th><th>Ballot</th><th>Role</th><th>Working Point</th><th>Kill</th></tr>
                <tbody v-for="(node_index,node) in nodeList.infos">
                    <tr>
                        <td v-if="node.status==1" rowspan="{{get_node(node_index).partitions.length + 1}}" "valign=middle"><a href="analyzer.html?init_machine={{node.address.host}}:{{node.address.port}}">{{node.address.host}}:{{node.address.port}}</a> (<font color=green> OK </font>) </td>
                        <td v-else rowspan="{{get_node(node_index).partitions.length + 1}}" valign="middle"><a href="analyzer.html?init_machine={{node.address.host}}:{{node.address.port}}">{{node.address.host}}:{{node.address.port}}</a> (<font color=red> X </font>)</td>                        
                        <td v-if="get_node(node_index).partitions.length > 0" colspan=5 style="display:none;"> &nbsp; </td>
                        <td v-else colspan=6> &nbsp; </td>
                    </tr>
                    <tr v-for="partition_index in (get_node(node_index).partitions.length)">
                        <td>{{get_node(node_index).partitions[partition_index].info.app_name}}</td>
                        <td>{{get_node(node_index).partitions[partition_index].config.pid.toString()}}</td>
                        <td>{{get_node(node_index).partitions[partition_index].config.ballot}}</td>
                        <td>{{get_node(node_index).partitions[partition_index].role}}</td>
                        <td><a href="analyzer.html?init_machine={{get_node(node_index).partitions[partition_index].working_point}}">{{get_node(node_index).partitions[partition_index].working_point}}</a></td>
                        <td><span class="glyphicon glyphicon-remove" @click="del(node.address, get_node(node_index).partitions[partition_index].info.is_stateful, get_node(node_index).partitions[partition_index].config.pid)"></span></td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="col-xs-1"></div>
    </div>

    <div id="info-modal" class="modal fade" role="dialog">
      <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Info</h4>
          </div>
          <div class="modal-body">
              {{info}}
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div>
      </div>
    </div>

</div>

<!--<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.min.js"></script>-->
<script src="js/vue.js"></script>
<script src="js/machine.js"></script>

{% endblock %}

